package android.dj.lbscamera.activities;

import java.util.LinkedList;
import java.util.List;

import android.app.Activity;
import android.app.Application;
import android.dj.lbscamera.entities.Loca;
import android.dj.lbscamera.entities.User;
import android.dj.lbscamera.utils.Constants;
import android.dj.lbscamera.utils.DefaultExceptionHandler;
import android.dj.lbscamera.utils.UseUtils;

public class BaseApplication extends Application {

	public Loca location = new Loca();
	public User user = new User();
	private List<Activity> activityList = new LinkedList<Activity>();
	private static BaseApplication instance;

	public BaseApplication() {

	}

	public static BaseApplication getInstance() {
		if (instance == null) {
			instance = new BaseApplication();
		}
		return instance;
	}

	public void addActivity(Activity activity) {
		activityList.add(activity);
	}

	public void exit() {
		for (Activity activity : activityList) {
			activity.finish();
		}
		System.exit(0);
	}
	
	public void closeAllActivity(){
		for (Activity activity : activityList) {
			activity.finish();
		}
	}

	@Override
	public void onCreate() {

		super.onCreate();
		Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler(
				this.getApplicationContext()));
	}
}
